import 'package:flutter/material.dart';
import 'package:flutter_base/inheritedwidget_demo/components/sharedata_widget.dart';
import 'package:flutter_base/inheritedwidget_demo/pages/other_test_widget.dart';

class InheritedWidgetTestPage extends StatefulWidget {
  const InheritedWidgetTestPage({super.key});

  @override
  State<InheritedWidgetTestPage> createState() => _InheritedWidgetTestPageState();
}

class _InheritedWidgetTestPageState extends State<InheritedWidgetTestPage> {
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('数据共享(InheritedWidget)')),
      body: Center(
        child: ShareDataWidget(
          data: count,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Padding(
                padding: EdgeInsets.only(bottom: 20.0),
                child: OtherTestWidget(),
              ),
              ElevatedButton(
                onPressed: () => setState(() => count++),
                child: const Text('Increment'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
